/******************** 
	作用:商户信息
	作者:蔡俊雄
	版本:V1.0
	时间:2015-08-01
********************/
$(function() {
	//-----------------上传图片设置-----------------
	//编辑器设置
	var uploadEditor = KindEditor.editor({
		uploadJson : '/Foundation/ImageTextReply?isUpfile=1',
		allowFileManager: true
	});
	//显示图片上传对话框
	function showImageUploadDialog(imageId, hiddenId) {
		uploadEditor.loadPlugin('image', function() {
			uploadEditor.plugin.imageDialog({
				imageUrl: $(hiddenId).val(),
				clickFn: function(url, title, width, height, border, align) {
					$(hiddenId).val(url);
					$(imageId).attr("src", url);
					uploadEditor.hideDialog();
				}
			});
		});
	}

	function initImageUploadDialog(btnId, imageId, hiddenId) {
		$(btnId).on("click", function(e) {
			showImageUploadDialog(imageId, hiddenId);
		});
	}

	$("#headImage").blur(function() {
		var url=$("#headImage").val();
		if(url)
			$("#previewImage").attr("src", url);
	});

	initImageUploadDialog("#upload,#previewImage", "#previewImage", "#headImage");
});